import { Button, Card, Form, Input, message } from "antd";

export const EditLoginScreen = ({
  setIsLogin,
}: {
  setIsLogin: (l: string) => void;
}) => {
  const handleSubmit = ({
    user,
    password,
  }: {
    user: string;
    password: string;
  }) => {
    if (!user || !password) {
      return;
    }
    if (user === "lookthis" && password === "123456") {
      setIsLogin("look_this");
      localStorage.setItem("look_this", "look_this");
    } else {
      message.error("用户名或密码错误");
    }
  };

  return (
    <Card>
      <Form onFinish={handleSubmit}>
        <Form.Item
          label="用户名"
          name={"user"}
          rules={[{ required: true, message: "请输入用户名" }]}
        >
          <Input placeholder={"用户名"} />
        </Form.Item>
        <Form.Item
          label="密码"
          name={"password"}
          rules={[{ required: true, message: "请输入密码" }]}
        >
          <Input placeholder={"密码"} type={"password"} />
        </Form.Item>

        <Form.Item>
          <Button type={"primary"} htmlType={"submit"}>
            登录
          </Button>
        </Form.Item>
      </Form>
    </Card>
  );
};
